import java.awt.Dimension;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.xy.XYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;

public class ScatterPlotSpike2 extends ApplicationFrame
{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * Creates a new demo instance.
	 * @param title the frame title.
	 */
	public ScatterPlotSpike2(String title)
	{
		super(title);
		JFreeChart chart = createChart();
		ChartPanel chartPanel = new ChartPanel(chart, false);
		chartPanel.setPreferredSize(new Dimension(500, 270));
		setContentPane(chartPanel);
	}

	/**
	 * Returns a sample dataset.
	 * @return The dataset.
	 */
	private static XYDataset createDataset()
	{
		XYSeries series1 = new XYSeries("Series 1");

		//random data
		series1.add(1.0, 1.0);
		series1.add(1.25, 1.0);
		series1.add(0.75, 1.25);
		series1.add(1.8, 2.1);
		series1.add(2.0, 2.0);
		series1.add(3.0, 3.0);
		series1.add(2.8, 2.1);
		series1.add(1.5, 2.0);
		series1.add(0.5, 3.0);
		series1.add(0.5, 1.0);
		series1.add(0.5, 1.1);
		series1.add(0.2, 0.8);

		XYDataset dataset = new XYSeriesCollection(series1);

		return dataset;
	}

	/**
	 * Create a horizontal bar chart with sample data in the range -3 to +3.
	 * @return The chart.
	 */
	private static JFreeChart createChart()
	{

		// create the chart...
		return ChartFactory.createScatterPlot("Scatter Plot: Fan-In V Fan-Out", // chart title
				"Fan-In", // domain axis label
				"Fan-Out", // range axis label
				createDataset(), // data
				PlotOrientation.VERTICAL, // Orientation
				true, // include legend
				true, // tooltips
				false // urls
				);

	}

	/**
	 * Starting point for the demonstration application.
	 * @param args ignored.
	 */
	public static void main(String[] args)
	{
		ScatterPlotSpike2 lcs = new ScatterPlotSpike2("Scatter Plot 2 - Spike");
		lcs.pack();
		RefineryUtilities.centerFrameOnScreen(lcs);
		lcs.setVisible(true);
	}

}
